Skip to content

fix(security): restrict GITHUB_TOKEN to contents:read on heartbeat workflow#175

Merged
saurabhjain1592 merged 1 commit intomainfrom
feature/security-workflow-permissions
Apr 29, 2026
Merged

fix(security): restrict GITHUB_TOKEN to contents:read on heartbeat workflow#175
saurabhjain1592 merged 1 commit intomainfrom
feature/security-workflow-permissions

Conversation

@saurabhjain1592
Copy link
Copy Markdown
Member

Summary

Resolves an open GitHub code-scanning alert: actions/missing-workflow-permissions on .github/workflows/heartbeat-real-stack.yml:20.

The heartbeat-real-stack workflow had no explicit top-level permissions: block, so GITHUB_TOKEN ran with the repository default token scopes — broader than this workflow needs. This is a CWE-275 (Permission Issues) class finding: the token had write capabilities the job never exercises.

Fix

Added a workflow-scoped permissions block:

permissions:
  contents: read

contents: read is the minimum required by actions/checkout@v4 to fetch the repo. The remaining steps (setup-python, pip install -e ., run a localhost-only E2E driver) need no GitHub-side write access.

If a future job in this workflow needs higher privileges, it should declare them at job level rather than widening the workflow-level grant.

Verification

  • YAML parses clean: python3 -c "import yaml; yaml.safe_load(open('.github/workflows/heartbeat-real-stack.yml'))" returns no error.
  • Diff is +3 lines, no logic change.

Test plan

  • CI green on this PR (the workflow itself runs on pull_request against main, so this branch will exercise the new permissions block end-to-end).
  • Code-scanning alert auto-closes on merge.

…rkflow

The heartbeat-real-stack workflow lacked an explicit top-level permissions
block, leaving GITHUB_TOKEN with the repository's default privileges
(potentially read/write across many scopes). This violates the principle
of least privilege (CWE-275: Permission Issues).

The workflow only needs to checkout the repo, set up Python, install the
SDK editable, and run a localhost-only E2E. None of those steps require
write access to any GitHub resource. Locking the token down to
contents: read at workflow scope addresses the code-scanning alert
'actions/missing-workflow-permissions'. Any job that later needs more
can declare its own permissions block at job level.

Resolves the open code-scanning alert on
.github/workflows/heartbeat-real-stack.yml:20.
@saurabhjain1592 saurabhjain1592 merged commit 58f61c3 into main Apr 29, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant